{% extends "base.html" %}

{% block content %}
<div class="max-w-md mx-auto">
    <div class="bg-white rounded-xl shadow-sm p-6 mt-8">
        <div class="text-center mb-6">
            <h2 class="text-2xl font-bold text-dark">注册</h2>
            <p class="text-dark-2 mt-2">创建账号开始你的编程之旅</p>
        </div>
        
        <form method="POST" action="{{ url_for('register') }}">
            <!-- 添加 CSRF 令牌字段 -->
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            
            {% if error %}
            <div class="bg-danger/10 rounded-lg p-4 mb-4">
                <div class="flex items-center">
                    <i class="fa fa-exclamation-circle text-danger mr-2"></i>
                    <p class="text-danger">{{ error }}</p>
                </div>
            </div>
            {% endif %}
            
            <div class="mb-4">
                <label for="username" class="block text-dark-2 mb-2">用户名</label>
                <input type="text" id="username" name="username" class="form-input" placeholder="请输入用户名" required>
            </div>
            
            <div class="mb-4">
                <label for="password" class="block text-dark-2 mb-2">密码</label>
                <input type="password" id="password" name="password" class="form-input" placeholder="请输入密码" required>
            </div>
            
            <div class="mb-6">
                <label for="confirm_password" class="block text-dark-2 mb-2">确认密码</label>
                <input type="password" id="confirm_password" name="confirm_password" class="form-input" placeholder="请再次输入密码" required>
            </div>
            
            <button type="submit" class="btn-primary w-full">注册</button>
            
            <div class="mt-4 text-center">
                <p class="text-dark-2">已有账号？ <a href="{{ url_for('login') }}" class="text-primary hover:underline">立即登录</a></p>
            </div>
        </form>
    </div>
</div>
{% endblock %}